local addon, ns = ...
local C = ns.shared.color
local L = ns.L
local GetFramerate = GetFramerate
local fps_update_interval = 10
local icons = {
	red = "Interface\\Addons\\Broker_Everything\\media\\fps_red",
	yellow = "Interface\\Addons\\Broker_Everything\\media\\fps_yellow",
	green = "Interface\\Addons\\Broker_Everything\\media\\fps_green",
	default = "Interface\\Addons\\Broker_Everything\\media\\fps",
}


local function fps_onupdate(self)
	local f = floor(GetFramerate())
	local _, playerClass = UnitClass("player")
	local suffix = C.class("fps ", playerClass)
	local dataobj = self.obj or LibStub:GetLibrary("LibDataBroker-1.1"):GetDataObjectByName(L["FPS"])

	if f < 20 then
		dataobj.icon = icons.red
		dataobj.text = C.brtred(f) .. suffix
	elseif f < 30 then
		dataobj.icon = icons.yellow
		dataobj.text = C.dkyellow(f) .. suffix
	else
		dataobj.icon = icons.green
		dataobj.text = C.dkgreen(f) .. suffix
	end
end


Broker_Everything:Register(L["FPS"],
	--GetItemIcon(44681),
	icons.default,
	0,
	0,
	0,
	0,
	0,
	fps_onupdate,
	fps_update_interval)
